/**
 * Created by pg on 2017/5/20.
 */
require.config({
    baseUrl: './',
    paths: {
        wx:"https://res.wx.qq.com/open/js/jweixin-1.2.0",
        weui:'lib/weui.min',
        vue: 'lib/vue.min',
        vuec:'lib/require-vuejs',
        Vuex:'lib/vuex.min',
        VueRouter: 'lib/vue-router.min',
        axios:'lib/axios.min',
        Base64:'lib/base64.min',
        utils:"utils/index",
        api:"api/index",
        sdk:"api/sdk",
        store:"store/index",
        router:"router/index",
        fetch:"utils/fetch",
        css: 'lib/css',
        text: 'lib/text',
        FastClick:'lib/fastclick'
    },
    shim: {
        vue: {exports: 'vue'},
        Base64: {exports: 'Base64'},
        VueRouter:['vue'],
        Vuex:['vue']
    },
    // enforceDefine: true,
    urlArgs: 'v=0.0.26'
});
require(["vue","router","store","views/app","FastClick","wx",'weui','utils'], function(Vue,router,store,initApp,FastClick,wx,weui,utils){
    //fastclick
    FastClick.attach(document.body);

    //vue实例初始化
    new Vue({
        router:router,
        store:store,
        el: "#app",
        //挂载初始页面
        render: function(h){
            return h(initApp);
        },
        data:function () {
            return {
            }
        }
    });
    //promise finally 方法扩展
    if(!Promise.prototype.finally) {
        Promise.prototype.finally = function (callback) {
            var Promise = this.constructor;
            return this.then(
                function (value) {
                    Promise.resolve(callback()).then(
                        function () {
                            return value;
                        }
                    );
                },
                function (reason) {
                    Promise.resolve(callback()).then(
                        function () {
                            throw reason;
                        }
                    );
                }
            );
        }
    }
});
